package com.fhz.a1911.fragment;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.fhz.a1911.MyViewModel;
import com.fhz.a1911.R;


public class RightFragment extends Fragment {
    private TextView rightTv;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View inflate = inflater.inflate(R.layout.fragment_right, container, false);

        rightTv = (TextView) inflate.findViewById(R.id.right_tv);

        MyViewModel myViewModel = new ViewModelProvider(getActivity()).get(MyViewModel.class);

        myViewModel.getMutableLiveData().observe(this, new Observer<String>() {
            @Override
            public void onChanged(String s) {
                rightTv.setText(s);
            }
        });
        return inflate;
    }
}